package com.yjyw.tiexie.activity.mine;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.yjyw.tiexie.R;
import com.yjyw.tiexie.util.ImageLoadUtil;
import com.luck.picture.lib.photoview.OnPhotoTapListener;
import com.luck.picture.lib.photoview.PhotoView;

public class BigImageUrlFragment extends Fragment {

    public static final String IMG_URL = "imgUrl";

    PhotoView mIvPic;

    private LayoutInflater mInflater;
    private Button take_frends;
    private Button take_pic;
    private Button btn_cancel;
    private String mimgUrl;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_big_image, null);
        mIvPic = view.findViewById(R.id.pv_pic);
        initListener();
        loadData();
        return view;
    }


    public void initListener() {
        mIvPic.setOnPhotoTapListener(new OnPhotoTapListener() {
            @Override
            public void onPhotoTap(ImageView view, float x, float y) {
                if (getActivity() != null) {
                    getActivity().finish();
                }
            }
        });
    }

    protected void loadData() {

        String imgUrl = getArguments().getString(IMG_URL);
        mimgUrl = imgUrl;
        ImageLoadUtil.showImgWithDefault(mIvPic, mimgUrl);
    }


}
